﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Text;

using Bussiness_Objects;

namespace DataObjects.ADO
{
    public class SqlTacGia : ITacGiaDao
    {
        public DataTable GetTable()
        {
            string sqlString = "sp_TACGIA_selectAll";
            return Db.Read(sqlString, null);
        }

        public DataTable GetById(object businessData)
        {
            TacGia tg = businessData as TacGia;
            if (tg != null)
            {
                tg.SetParameterSelectID();
                string sqlString = "sp_TACGIA_selectById";
                return Db.Read(sqlString, tg.parms);
            }
            return null;
        }

        public string Insert(object businessData)
        {
            TacGia tg = businessData as TacGia;
            if (tg != null)
            {
                tg.SetParameterInsert();
                string sqlString = "sp_TACGIA_insert";
                return Db.ExecuteStoreProcedure(sqlString, tg.parms);
            }
            return "Error";
        }

        public string Update(object businessData)
        {
            TacGia tg = businessData as TacGia;
            if (tg != null)
            {
                tg.SetParameterUpdate();
                string sqlString = "sp_TACGIA_update";
                return Db.ExecuteStoreProcedure(sqlString, tg.parms);
            }
            return "Error";
        }
    }
}
